//
// Created by fazhehy on 2024/6/8.
//

#include "task.h"

float mx_offset, my_offset, mz_offset;
float mx_k, my_k, mz_k;
float mag_angle;
char str[10][64];

uint8_t nop_task(uint8_t keyNum)
{
    asm("nop");
    return keyNum;
}

uint8_t set_mag_deviate_angle(uint8_t keyNum)
{
    if (keyNum == UP || keyNum & ENCODER_POS_PREFIX){
        mag_angle += 1.0f;
    }
    else if (keyNum == DOWN || keyNum & ENCODER_NEG_PREFIX){
        mag_angle -= 1.0f;
    }
    else if (keyNum == BACK){
        return BACK;
    }
    st7789_printf(40, 0, "mag_angle:%f", mag_angle);
    return NO_SHOW;
}

uint8_t record_point_task(uint8_t keyNum)
{
    st7789_printf(0, 40, "record point");
    if (keyNum == BACK){
        return BACK;
    }
    return NO_SHOW;
}

uint8_t flash_write_point_task(uint8_t keyNum)
{
//    flash_write_gnss_point();
    HAL_Delay(1);
    st7789_printf(0, 40, "flash write OK!");
    HAL_Delay(100);
    return BACK;
}

uint8_t remote_control_task(uint8_t keyNum)
{
    return keyNum;
}

uint8_t mag_calibration_task(uint8_t keyNum)
{
    st7789_printf(0, 40, "mag calibration");
    if (keyNum == BACK){
        return BACK;
    }
    return NO_SHOW;
}

uint8_t show_attitude_task(uint8_t keyNum)
{
    st7789_printf(0, 40, "show attitude");
    if (keyNum == BACK){
        return BACK;
    }
    return NO_SHOW;
}

uint8_t flash_write_param_task(uint8_t keyNum)
{
    //    st7789_clear();
    flash_write_parameter();
    st7789_printf(0, 40, "flash write OK!");
    HAL_Delay(100);
//    st7789_clear();
    return BACK;
}
